selector_path_prepend_class (path, str);
}
+static gboolean
+is_widget_class_name (const gchar *str)
+{
+ /* Do a pretty lax check here, not all
+ * widget class names contain only CamelCase
+ * (gtkmm widgets don't), but at least part of
+ * the name will be CamelCase, so check for
+ * the first uppercase char */
+ while (*str)
+ {
+ if (g_ascii_isupper (*str))
+ return TRUE;
+
+ str++;
+ }
+
+ return FALSE;
+}
+
static GTokenType
parse_selector (GtkCssProvider *css_provider,
GScanner *scanner,
parse_classes (path, pos + 1);
}
}
- else if (g_ascii_isupper (scanner->value.v_identifier[0]))
+ else if (is_widget_class_name (scanner->value.v_identifier))
{
gchar *pos;
else
selector_path_prepend_type (path, scanner->value.v_identifier);
}
- else if (g_ascii_islower (scanner->value.v_identifier[0]))
+ else if (_gtk_style_context_check_region_name (scanner->value.v_identifier))
{
GtkRegionFlags flags = 0;
gchar *region_name;
return G_TOKEN_IDENTIFIER;
}
}
- else if (prop[0] == '-' &&
- g_ascii_isupper (prop[1]))
+ else if (prop[0] == '-')
{
GValue *val;
return classes;
}
+gboolean
+_gtk_style_context_check_region_name (const gchar *str)
+{
+ g_return_val_if_fail (str != NULL, FALSE);
+
+ if (!g_ascii_islower (str[0]))
+ return FALSE;
+
+ while (*str)
+ {
+ if (*str != '-' &&
+ !g_ascii_islower (*str))
+ return FALSE;
+
+ str++;
+ }
+
+ return TRUE;
+}
+
/**
* gtk_style_context_add_region:
* @context: a #GtkStyleContext
*
* would apply to even and odd rows, respectively.
*
+ * <note><para>Region names must only contain lowercase letters
+ * and '-', starting always with a lowercase letter.</para></note>
+ *
* Since: 3.0
**/
void
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (region_name != NULL);
+ g_return_if_fail (_gtk_style_context_check_region_name (region_name));
priv = context->priv;
region_quark = g_quark_from_string (region_name);
void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context);
void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context,
GtkWidget *widget);
+gboolean _gtk_style_context_check_region_name (const gchar *str);
+
void gtk_style_context_invalidate (GtkStyleContext *context);
void gtk_style_context_reset_widgets (GdkScreen *screen);
* the hierarchy defined in @path. See
* gtk_style_context_add_region().
*
+ * <note><para>Region names must only contain lowercase letters
+ * and '-', starting always with a lowercase letter.</para></note>
+ *
* Since: 3.0
**/
void
g_return_if_fail (path != NULL);
g_return_if_fail (path->elems->len != 0);
g_return_if_fail (name != NULL);
+ g_return_if_fail (_gtk_style_context_check_region_name (name));
if (pos < 0 || pos > path->elems->len)
pos = path->elems->len - 1;